package start.spring.basic.flowable.controller.biz.leave;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import start.spring.basic.flowable.common.SysConstant;
import start.spring.basic.flowable.controller.BaseController;
import start.spring.basic.flowable.entity.BizLeave;
import start.spring.basic.flowable.service.biz.leave.IBizLeaveService;
import start.spring.basic.log.ServiceLog;
import start.spring.basic.response.ResponseData;

/**
 * 
 * @author xuyy
 * @date 2023-09-02
 *
 */
@RestController
@RequestMapping("/leave")
@Api(tags = "请假相关接口")
public class BizLeaveController extends BaseController {
	
    @Autowired
    private IBizLeaveService bizLeaveService;
    
    @ServiceLog(businessType = "查询请假详情", systemType = SysConstant.SYSTEM_TYPE, recordResult = true, userId = "")
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "查询请假详情", notes = "")
    public ResponseData<BizLeave> detail(@PathVariable(value = "id") String id) {
    	BizLeave bizLeave = this.bizLeaveService.selectDetailById(id);
    	if(bizLeave!=null) {
    		return ResponseData.successData(bizLeave);
    	}else {
    		return ResponseData.errorMsg("未查询到详细信息！");
    	}
    }
	
    @ServiceLog(businessType = "新增请假", systemType = SysConstant.SYSTEM_TYPE, recordResult = true, userId = "")
    @PostMapping("/add")
    @ApiOperation(value = "新增请假", notes = "")
    public ResponseData<String> add(String tjzt,@RequestBody BizLeave bizLeave) {
        return this.bizLeaveService.insertBizLeave(tjzt,bizLeave);
    }
	
    @ServiceLog(businessType = "删除请假", systemType = SysConstant.SYSTEM_TYPE, recordResult = true, userId = "")
    @PostMapping("/remove")
    @ApiOperation(value = "删除请假", notes = "")
    public ResponseData<String> remove(@RequestBody List<String> ids) {
    	return this.bizLeaveService.deleteBizLeaveByIds(ids);
    }
}
